package cn.sc.allinpay.allfavour.base.widget;

import android.content.Context;
import android.support.v7.widget.AppCompatImageView;
import android.util.AttributeSet;

/**
 * 
 * @description 正方形ImageView
 * @author pany
 * @date 2017年3月13日下午2:11:31
 */
public class SquareImageView extends AppCompatImageView {

	public SquareImageView(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	public SquareImageView(Context context) {
		super(context);
	}

	@Override
	protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
		// setMeasuredDimension(getDefaultSize(0, widthMeasureSpec),
		// getDefaultSize(0, heightMeasureSpec));
		//
		// // Children are just made to fill our space.
		// int childWidthSize = getMeasuredWidth();
		// // 高度和宽度一样
		// widthMeasureSpec = MeasureSpec.makeMeasureSpec(childWidthSize,
		// MeasureSpec.EXACTLY);
		// heightMeasureSpec = widthMeasureSpec;
		super.onMeasure(widthMeasureSpec, heightMeasureSpec);
		setMeasuredDimension(getMeasuredWidth(), getMeasuredWidth());
	}
}
